<?php
// session 验证
if(isset($_REQUEST['code'])){
    session_start();
    if(strtolower($_REQUEST['code'])==strtolower($_SESSION['code'])){
        header("Content-type:text/html;charset=UTF8");
        echo "<font color='#0000CC'>正确</font>";
    }else{
        header("Content-type:text/html;charset=UTF8");
        echo '<font color="#CC0000">错误</font>';
    }
}
?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>验证</title>
</head>
<body>
    <form method="post" action="form.php">
        <p>验证码图片<img src="img.php" alt="看不清，换一张"
                     onclick="this.src=this.src+'?'+new Date().getTime();"
                     />
        </p>
        <p>请输入验证码：<input type="text" name="code" value=""/></p>
        <p><input type="submit" value="提交" style="padding: 5px 20px"/></p>
    </form>
</body>
</html>
